package com.stek.spec;

import java.util.ArrayList;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.stek.R;
import com.stek.utils.Utils;

public class SpecAdapter extends FragmentStatePagerAdapter {
	// ====================================================
	private static ArrayList<SpecFragment> fragments;

	// ====================================================

	public SpecAdapter(FragmentManager fm) {
		super(fm);
	}

	public SpecAdapter(FragmentManager fm, Context context) {
		super(fm);
		fragments = new ArrayList<SpecFragment>();
		fragments.add(SpecFragment.newInstance(context
				.getString(R.string.feature)));
		if (Utils.Telephony.hasTelephony(context)) {
			fragments.add(SpecFragment.newInstance(context
					.getString(R.string.telephony)));
		}
		fragments.add(SpecFragment.newInstance(context
				.getString(R.string.display)));
		fragments.add(SpecFragment.newInstance(context
				.getString(R.string.memory)));
		fragments
				.add(SpecFragment.newInstance(context.getString(R.string.data)));
		if (Utils.CameraHardware.hasCameraBack(context)
				|| Utils.CameraHardware.hasCameraFront(context)) {
			fragments.add(SpecFragment.newInstance(context
					.getString(R.string.camera)));
		}
		fragments.add(SpecFragment.newInstance(context
				.getString(R.string.battery)));

		fragments.add(SpecFragment.newInstance(context
				.getString(R.string.sensor)));
	}

	@Override
	public CharSequence getPageTitle(int position) {
		// TODO Auto-generated method stub
		return fragments.get(position).getArguments().getString("type");
	}

	@Override
	public Fragment getItem(int arg0) {
		return fragments.get(arg0);
	}

	@Override
	public int getCount() {
		return fragments.size();
	}

}
